<?php

namespace app\common\model\course;

use app\admin\model\Comment;
use app\admin\model\course\Cate;
use app\admin\model\course\Catelog;
use think\Model;

/**
 * Course
 */
class Course extends Model
{
    // 表名
    protected $name = 'course';

    // 自动写入时间戳字段
    protected $autoWriteTimestamp = true;

    public function comments()
    {
        return $this->belongsToMany(Comment::class,'course_comment');
    }

    public function cate()
    {
        return $this->belongsTo(Cate::class);
    }

    public function cateLog()
    {
        return $this->belongsTo(Catelog::class);
    }


    public function getCoverAttr($value)
    {
        return !$value ? '' : full_url($value);
    }

    public function getVideoAttr($value)
    {
        return !$value ? '' : full_url($value);
    }

}
